package top.chj.day16.dateclass;

import org.junit.Test;

import java.time.*;
import java.util.Set;

/**
 * @Auther:小陈的Java
 */
public class DateInitDemo {
    @Test
    public void test1(){
        Instant now = Instant.now();
        System.out.println(now);//2022-06-16T12:38:42.621Z
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate);//2022-06-16
        LocalTime localTime = LocalTime.now();
        System.out.println(localTime);//20:38:42.683
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);//2022-06-16T20:38:42.683
        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        System.out.println(zonedDateTime);//2022-06-16T20:38:42.684+08:00[Asia/Shanghai]
    }
    @Test
    public void test2(){
        System.out.println(Year.now());//2022
        System.out.println(YearMonth.now());//2022-06
        System.out.println(MonthDay.now());//--06-16
    }
    @Test
    public void test3(){
        LocalDate localDate = LocalDate.of(2012,11,12);
        System.out.println(localDate);
        LocalTime localTime = LocalTime.of(12,3,5);
        System.out.println(localTime);
        LocalDateTime localDateTime = LocalDateTime.of(2012,12,2,23,4,1);
        System.out.println(localDateTime);
        LocalDateTime localDateTime1 = LocalDateTime.of(localDate,localTime);
        System.out.println(localDateTime1);
    }
    @Test
    public void test4(){
        Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();
        System.out.println(availableZoneIds);
        System.out.println(ZoneId.systemDefault());
    }
    @Test
    public void test5(){
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime);
        System.out.println(zonedDateTime.withZoneSameInstant(ZoneId.of("America/Cuiaba")));
    }
    @Test
    public void test6(){
        LocalDateTime localDateTime = LocalDateTime.of(2012, Month.JANUARY, 12, 21, 12);
        System.out.println(localDateTime);
    }
}
